package com.yuanfeng.order.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yuanfeng.commoms.config.YFConfig;
import com.yuanfeng.commoms.constant.CommonStatusEnum;
import com.yuanfeng.commoms.constant.CommonType;
import com.yuanfeng.commoms.dto.goods.ActivityGoodsDetailDTO;
import com.yuanfeng.commoms.dto.goods.ReceiveGoodsDetailsDTO;
import com.yuanfeng.commoms.dto.userms.UserTokenBeanDTO;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.*;
import com.yuanfeng.commoms.util.Json.JsonUtils;
import com.yuanfeng.commoms.util.querypage.PageUtils;
import com.yuanfeng.commoms.util.querypage.Query;
import com.yuanfeng.commoms.vo.activity.AppSeckillGoodsQueryResultVO;
import com.yuanfeng.commoms.vo.activity.ManjianzengzhePromotionContentQueryResultVO;
import com.yuanfeng.commoms.vo.goods.ReceiveGoodsDetailsVO;
import com.yuanfeng.commoms.vo.order.ShoppingCartVO;
import com.yuanfeng.commoms.vo.user.UserInfoVO;
import com.yuanfeng.order.dto.EntityObjectsDTO;
import com.yuanfeng.order.entity.OrderUserCartEntity;
import com.yuanfeng.order.feign.*;
import com.yuanfeng.order.mapper.OrderUserCartMapper;
import com.yuanfeng.order.service.OrderUserCartService;
import io.seata.core.context.RootContext;
import io.seata.core.exception.TransactionException;
import io.seata.spring.annotation.GlobalTransactional;
import io.seata.tm.api.GlobalTransactionContext;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

/**
 * @ClassName OrderUserCartServiceImpl
 * @Description 购物车表
 * @Author cyp
 * @Date 2023-05-25 13:39:42
 * @Version 1.0
 **/
@Service
public class OrderUserCartServiceImpl extends ServiceImpl<OrderUserCartMapper, OrderUserCartEntity>
        implements OrderUserCartService {
    @Autowired
    private BusinessServiceClient businessServiceClient;
    @Autowired
    private BaseServiceClient baseServiceClient;
    @Autowired
    private UserServiceClient userServiceClient;
    @Autowired
    private GoodServiceClient goodServiceClient;
    @Autowired
    private ActivityServiceClient activityServiceClient;

    final Logger log = LoggerFactory.getLogger(OrderUserCartServiceImpl.class);

    @Override
    public Integer selectCurrentCartQuantity(String userId, Integer goodsId) {
        return this.baseMapper.selectCurrentCartQuantity(userId, goodsId);
    }

    @Override
    public ResponseResult changeGoodsNum(Map<String, Object> map) {
        UserInfoVO userInfo = ParseTokenUtils.getUserInfoByToken(map.get("token").toString());
        if (null != userInfo) {
            Integer goodsId = (Integer) map.get("goodsId");
            try {
                ResponseResult rr = businessServiceClient.getGoodsDetails(goodsId);
                if (rr.getCode() != 1) {
                    return ResponseResult.fail(0, "未获取到信息！");
                } else {
                    String goodsDetails = rr.getData().toString();
                    // json转对象
                    ReceiveGoodsDetailsVO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                            ReceiveGoodsDetailsVO.class);
                    Integer goodsStock = receiveGoodsDetails.getGoodsStock();
                    Integer goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                    Integer commonLimit = receiveGoodsDetails.getCommonLimit();
                    Integer goodsMinSale = receiveGoodsDetails.getGoodsMinSale();
                    Integer goodsNum = (Integer) map.get("goodsNum");
                    if (commonLimit != 0) {
                        if (goodsNum > goodsMaxSale || goodsNum < goodsMinSale) {
                        } else {
                            if (goodsNum > goodsStock) {
                                return ResponseResult.fail(BizCodeEnume.USER_CART_STOCK_ERROR.getCode(), BizCodeEnume.USER_CART_STOCK_ERROR.getMsg());
                            } else {
                                Boolean IsSuccess = this.baseMapper.changeGoodsNum(userInfo.getUserId(), goodsId, goodsNum);
                                if (IsSuccess) {
                                    rr.setCode(1);
                                    return ResponseResult.success();
                                } else {
                                    rr.setCode(2);
                                    return ResponseResult.fail(BizCodeEnume.SYSTEM_ERROR.getCode(), BizCodeEnume.SYSTEM_ERROR.getMsg());
                                }
                            }
                        }
                    } else {
                        if (goodsNum > goodsStock) {
                            rr.setCode(2);
                            return ResponseResult.fail(BizCodeEnume.USER_CART_STOCK_ERROR.getCode(), BizCodeEnume.USER_CART_STOCK_ERROR.getMsg());
                        } else {
                            Boolean IsSuccess = this.baseMapper.changeGoodsNum(userInfo.getUserId(), goodsId, goodsNum);
                            if (IsSuccess) {
                                rr.setCode(1);
                                return ResponseResult.success();
                            } else {
                                rr.setCode(2);
                                return ResponseResult.fail(BizCodeEnume.SYSTEM_ERROR.getCode(), BizCodeEnume.SYSTEM_ERROR.getMsg());
                            }
                        }
                    }
                }
            } catch (Exception e) {
            }
        } else {
            return ResponseResult.fail(BizCodeEnume.TOKEN_IS_ILLEGAL.getCode(), BizCodeEnume.TOKEN_IS_ILLEGAL.getMsg());
        }
        return ResponseResult.fail(BizCodeEnume.SYSTEM_ERROR.getCode(), BizCodeEnume.SYSTEM_ERROR.getMsg());
    }

    @Override
    public ResponseResult batchDeleteGoods(Map<String, Object> map) {
        UserInfoVO userInfo = ParseTokenUtils.getUserInfoByToken(map.get("token").toString());
        if (null == userInfo) {
            return ResponseResult.fail(BizCodeEnume.TOKEN_IS_ILLEGAL.getCode(), BizCodeEnume.TOKEN_IS_ILLEGAL.getMsg());
        }
        try {
            String userId = userInfo.getUserId();
            @SuppressWarnings("unchecked")
            List<Integer> goodsIdList = (List<Integer>) map.get("goodsId");
            this.baseMapper.batchDeleteGoods(userId, goodsIdList);

        } catch (Exception e) {
        }
        return ResponseResult.success();
    }

    @Override
    public ResponseResult queryShoppingCart(Map<String, Object> map) {
        //plus状态查询
        Integer selectplus = (Integer) baseServiceClient.queryMerchantPlusRule().getData();

        String token = (String) map.get("token");
        try {
            String userId = RedisUtil.get(YFConfig.YF_USER_TOKEN_USERID + token);
            UserInfoVO userInfo = ParseTokenUtils.getUserInfoByToken(token);
            Integer goodsType = null == map.get("goodsType") ? 1 : (StringUtils.isBlank(map.get("goodsType").toString()) ? 1 : Integer.parseInt(map.get("goodsType").toString()));
            //查询用户购物车
            List<OrderUserCartEntity> cartList = this.baseMapper.selectList(new LambdaQueryWrapper<OrderUserCartEntity>()
                    .eq(OrderUserCartEntity::getUserId, userId)
                    .eq(OrderUserCartEntity::getGoodsType, goodsType)
                    .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode())
                    .orderByDesc(OrderUserCartEntity::getInsertCartTime));
            //查询店铺名和店铺id
            List<EntityObjectsDTO> cartListByShopName = this.baseMapper.queryShoppingCartByShopName(userId, goodsType);
            Map<String, Object> resultMap = new HashMap<>();
            Integer numberOfValidProducts = 0;
            List<EntityObjectsDTO> cartListByShopNameList = new ArrayList<>();
            List<OrderUserCartEntity> userXiaJiaCartList = new ArrayList<>();
            //遍历店铺
            for (EntityObjectsDTO entityObjects : cartListByShopName) {
                Integer goodsNum = 0;
                Integer shopInvoices = null;
                Integer plus_goods = null;
                Integer shopIdTmp = entityObjects.getShopId();
                Integer result = 0;
                Map<String, Object> paramTmp = new HashMap<>();
                paramTmp.put("shopId", shopIdTmp);
                //查询发票功能是否开启
                ResponseResult data = businessServiceClient.queryShopInvoiceSwitchStatus(paramTmp);
                entityObjects.setInvoiceActive((Integer) data.getData());
                List<OrderUserCartEntity> userShoppingCartList = new ArrayList<>();
                //遍历用户购物车
                for (OrderUserCartEntity userShoppingCart : cartList) {
                    //设置会员折扣
                    userShoppingCart.setPlusMember(userInfo.getPlusMember());
                    userShoppingCart.setPlusDiscount(userInfo.getPlusDiscount());
                    if (entityObjects.getShopId().toString().equals(userShoppingCart.getShopId().toString())) {
                        Integer goodsId = userShoppingCart.getGoodsId();
                        Integer goodsStatus = null;
                        Integer goodsStock = null;
                        Integer goodsMaxSale = null;
                        Integer goodsMinSale = null;
                        Integer activityStatus = null;
                        Integer activityGoodsState = null;
                        Integer toBuyMaxNum = null;
                        Integer purchased = null;
                        BigDecimal goodsPrice = new BigDecimal(0);
                        String pic = null;
                        //查询商品详细信息
                        ResponseResult goodResult = goodServiceClient.getGoodsDetails(goodsId);
                        if (goodResult.getCode() != CommonType.commonStatus.YES.getCode()) {
                            return ResponseResult.fail(BizCodeEnume.NO_INFORMATION_OBTAINED.getCode());
                        } else {
                            String goodsDetails = goodResult.getData().toString();
                            // json转对象
                            ReceiveGoodsDetailsDTO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                                    ReceiveGoodsDetailsDTO.class);
                            activityStatus = receiveGoodsDetails.getActivityStatus();
                            activityGoodsState = receiveGoodsDetails.getActivityGoodsState();
                            ActivityGoodsDetailDTO agd = receiveGoodsDetails.getActivityGoodsDetail();
                            if (activityStatus == 1) {

                            } else if (activityStatus == 2 && receiveGoodsDetails.getActivityGoodsState() == 1) {
                                HashMap<String, Object> map1 = new HashMap<>();
                                map1.put("token", token);
                                map1.put("goodsId", goodsId);
                                map1.put("commonId", receiveGoodsDetails.getCommonId());
                                ResponseResult resp = activityServiceClient.seckillCheckLimit(map1);
                                if (resp.getData() == null) {
                                    resp.setData(0);
                                }
                                purchased = (Integer) resp.getData();
                                goodsPrice = agd.getActivityPrice();
                                pic = receiveGoodsDetails.getGoodsImage();
                                shopInvoices = receiveGoodsDetails.getShopInvoices();
                                goodsStatus = receiveGoodsDetails.getCartStatus();
                                goodsStock = receiveGoodsDetails.getGoodsStock();
                                goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                                goodsMinSale = receiveGoodsDetails.getGoodsMinSale();

                            } else if (activityStatus == 3 && receiveGoodsDetails.getActivityGoodsState() == 1) {
                                HashMap<String, Object> map1 = new HashMap<>();
                                map1.put("token", token);
                                map1.put("goodsId", goodsId);
                                map1.put("commonId", receiveGoodsDetails.getCommonId());
                                ResponseResult resp = activityServiceClient.discountCheckLimit(map1);
                                if (resp.getData() == null) {
                                    resp.setData(0);
                                }
                                purchased = (Integer) resp.getData();
                                goodsPrice = agd.getActivityPrice();
                                pic = receiveGoodsDetails.getGoodsImage();
                                shopInvoices = receiveGoodsDetails.getShopInvoices();
                                goodsStatus = receiveGoodsDetails.getCartStatus();
                                goodsStock = receiveGoodsDetails.getGoodsStock();
                                goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                                goodsMinSale = receiveGoodsDetails.getGoodsMinSale();
                            } else {
                                if (activityStatus == 5) {
                                    List<ManjianzengzhePromotionContentQueryResultVO> promotionContents = activityServiceClient.selectReductionPolicyPromotionContent(receiveGoodsDetails.getCommonId());
                                    for (ManjianzengzhePromotionContentQueryResultVO r : promotionContents) {
                                        Integer discountType = r.getDiscountType();
                                        ;
                                        //满折
                                        if (discountType == 3) {
                                            activityStatus = 6;
                                            break;
                                        }
                                    }
                                }
                                pic = receiveGoodsDetails.getGoodsImage();
                                if (goodsType.intValue() == 1 && receiveGoodsDetails.getGoodsType().intValue() == 2) {
                                    // 用户购买供应商商品为商品指导价
//										goodsPrice = receiveGoodsDetails.getGuide_price();
                                    goodsPrice = receiveGoodsDetails.getGoodsPrice();
                                } else {
                                    goodsPrice = receiveGoodsDetails.getGoodsPrice();
                                }
                                shopInvoices = receiveGoodsDetails.getShopInvoices();
                                goodsStatus = receiveGoodsDetails.getCartStatus();
                                goodsStock = receiveGoodsDetails.getGoodsStock();
                                goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                            }
                            plus_goods = receiveGoodsDetails.getPlusGoods();
                            toBuyMaxNum = dealActivityInfo(token, goodsId, activityStatus, goodsMaxSale, goodsStock);
                        }
                        ReceiveGoodsDetailsDTO newReceiveGoodsDetails = JsonUtils.string2Obj(goodResult.getData().toString(),
                                ReceiveGoodsDetailsDTO.class);

                        userShoppingCart.setDealerGoodsFlag(null == newReceiveGoodsDetails.getDealerGoodsFlag() ? 0 : newReceiveGoodsDetails.getDealerGoodsFlag());
                        // 设置最大售卖数量、库存及商品上下架状态
                        userShoppingCart.setGoodsImage(pic);
                        userShoppingCart.setGoodsStock(goodsStock);
                        userShoppingCart.setGoodsPrice(Double.parseDouble(goodsPrice.toString()));
                        userShoppingCart.setGoodsIsShelves(goodsStatus);
                        userShoppingCart.setGoodsMaxSale(goodsMaxSale);
                        userShoppingCart.setGoodsName(newReceiveGoodsDetails.getGoodsName());
                        userShoppingCart.setCommonIsXian(activityStatus);
                        userShoppingCart.setGoodsMinSale(goodsMinSale);
                        userShoppingCart.setActivityGoodsState(activityGoodsState);
                        userShoppingCart.setPurchased(purchased);
                        userShoppingCart.setPlusMember(userInfo.getPlusMember());
                        userShoppingCart.setPlusDiscount(userInfo.getPlusDiscount());
                        userShoppingCart.setPlusGoods(plus_goods);
                        userShoppingCart.setGoodsStartTime(newReceiveGoodsDetails.getGoodsStartTime());
                        userShoppingCart.setGoodsIsShelves(newReceiveGoodsDetails.getGoodsIsShelves());
                        if (2 == activityStatus || 3 == activityStatus) {
                            userShoppingCart.setToBuyMaxNum(toBuyMaxNum);
                        }
                        userShoppingCart.setActivityGoodsDetail(newReceiveGoodsDetails.getActivityGoodsDetail());
                        Integer num = userShoppingCart.getGoodsNum();
                        BigDecimal goodsNumber = new BigDecimal(num);
                        BigDecimal totalPrice = goodsNumber.multiply(goodsPrice);
                        userShoppingCart.setGoodsTotalPrice(totalPrice);

                        // 计算共有几件商品
                        Integer goodsnum = userShoppingCart.getGoodsNum();
                        goodsNum += goodsnum;
                        entityObjects.setGoodsNum(goodsNum);

                        if (userShoppingCart.getGoodsSpec() != null) {
                            userShoppingCart.setSpecification(JsonUtils.parseJsonDouble(
                                    UnicodeUtils.unicode2String(userShoppingCart.getGoodsSpec())));
                        } else {
                            userShoppingCart
                                    .setGoodsSpecChineseValue(userShoppingCart.getGoodsSpecChineseValue());
                        }
                        // userShoppingCart.setGoods_Spec_ChineseValue(userShoppingCart.getGoods_spec_chineseValue());
                        if (userShoppingCart.getGoodsIsShelves() == 1 && newReceiveGoodsDetails.getCommonState() != 10
                                && userShoppingCart.getGoodsStock() > 0 && newReceiveGoodsDetails.getCommonStock() > 0) {
                            userShoppingCartList.add(userShoppingCart);
                            numberOfValidProducts++;
                        } else {
                            userXiaJiaCartList.add(userShoppingCart);
                        }
                    }
                }
                entityObjects.setShopInvoices(shopInvoices);
                entityObjects.setPlusStatus(selectplus);
                entityObjects.setGoodsDetailsList(userShoppingCartList);
                if (!userShoppingCartList.isEmpty()) {
                    cartListByShopNameList.add(entityObjects);
                }
            }
            resultMap.put("numberOfValidProducts", numberOfValidProducts);
            resultMap.put("list", cartListByShopNameList);
            resultMap.put("invalidProductList", userXiaJiaCartList);
            return ResponseResult.success(resultMap);

        } catch (Exception e) {
            e.printStackTrace();
            log.info("queryShoppingCartErrorResults:" + e.getMessage());
            return ResponseResult.fail(e.getMessage());
        }
    }

    @Override
    public ResponseResult deleteInvalidProductByCart(Map<String, Object> map) {
        String token = (String) map.get("token");
        try {
            String userId = RedisUtil.get(YFConfig.YF_USER_TOKEN_USERID + token);
            Integer goodsType = null == map.get("goodsType") ? 1 : (StringUtils.isBlank(map.get("goodsType").toString()) ? 1 : Integer.parseInt(map.get("goodsType").toString()));
            //判断是否为品牌店铺用户
            UserInfoVO vo = new UserInfoVO();
            vo.setUserId(userId);
            ResponseResult userInfoResult = userServiceClient.queryUserInfo(vo);
            Map<String, Object> userMap = (Map<String, Object>) userInfoResult.getData();
            if (userMap.get("shopId") != null) {
                goodsType = 3;
            }
            //查询用户购物车
            List<OrderUserCartEntity> cartList = this.baseMapper.selectList(new LambdaQueryWrapper<OrderUserCartEntity>()
                    .eq(OrderUserCartEntity::getUserId, userId)
                    .eq(OrderUserCartEntity::getGoodsType, goodsType)
                    .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode())
                    .orderByDesc(OrderUserCartEntity::getInsertCartTime));
            //查询店铺名和店铺id
            List<EntityObjectsDTO> cartListByShopName = this.baseMapper.queryShoppingCartByShopName(userId, goodsType);
            List<Integer> goodIdList = new ArrayList<>();
            //遍历店铺
            for (EntityObjectsDTO entityObjects : cartListByShopName) {
                //遍历用户购物车
                for (OrderUserCartEntity userShoppingCart : cartList) {
                    if (entityObjects.getShopId().toString().equals(userShoppingCart.getShopId().toString())) {
                        Integer goodsId = userShoppingCart.getGoodsId();
                        //查询商品详细信息
                        ResponseResult goodResult = goodServiceClient.getGoodsDetails(goodsId);
                        if (goodResult.getCode() != CommonType.commonStatus.YES.getCode()) {
                            return ResponseResult.fail(BizCodeEnume.NO_INFORMATION_OBTAINED.getCode());
                        } else {
                            String goodsDetails = goodResult.getData().toString();
                            // json转对象
                            ReceiveGoodsDetailsDTO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                                    ReceiveGoodsDetailsDTO.class);
                            if (receiveGoodsDetails == null) {
                                return ResponseResult.fail(BizCodeEnume.NO_GOODS);
                            }
                            // 无效商品
                            if (receiveGoodsDetails.getGoodsIsShelves() != 1 || receiveGoodsDetails.getCommonState() == 10
                                    || receiveGoodsDetails.getGoodsStock() <= 0 || receiveGoodsDetails.getCommonStock() <= 0) {
                                goodIdList.add(goodsId);
                            }
                        }
                    }
                }
            }
            this.baseMapper.batchDeleteGoods(userId, goodIdList);
            return ResponseResult.success();
        } catch (Exception e) {
            e.printStackTrace();
            log.info("deleteInvalidProductByCart:" + e.getMessage());
            return ResponseResult.fail(e.getMessage());
        }
    }

    @Override
    @GlobalTransactional(rollbackFor = Exception.class)
    public ResponseResult insertShoppingCart(Map<String, Object> map) throws TransactionException {
        String token = (String) map.get("token");

        try {
            UserInfoVO userInfo = ParseTokenUtils.getUserInfoByToken(token);

            String userId = userInfo.getUserId();
            //判断是否为品牌店铺用户
            UserInfoVO vo = new UserInfoVO();
            vo.setUserId(userId);
            ResponseResult userInfoResult = userServiceClient.queryUserInfo(vo);
            Map<String, Object> userMap = (Map<String, Object>) userInfoResult.getData();
            String sellerShopId = userInfo.getShopId();
            if (userMap != null) {
                sellerShopId = String.valueOf(userMap.get("shopId"));
            }
            Integer goodsId = Integer.parseInt(map.get("goodsId").toString());
            Integer goodsNum = Integer.parseInt(map.get("goodsNum").toString());
            return addShoppingCart(userId, goodsId, goodsNum, sellerShopId);
        } catch (Exception e) {
            e.printStackTrace();
            // 回滚
            GlobalTransactionContext.reload(RootContext.getXID()).rollback();
            return ResponseResult.fail(e.getMessage());
        }

    }

    @Override
    public ResponseResult getShoppongCartList(ShoppingCartVO param) throws IllegalAccessException {
        Map data = ParseMapUtils.beanToMap(param);
        IPage<ShoppingCartVO> page = this.baseMapper.getShoppongCartList(new Query<ShoppingCartVO>().getPage(data),
                param);
        return ResponseResult.success(PageUtils.getPage(page));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public ResponseResult updateOrderUserCarByMap(Map<String, Object> map) {
        Integer count = this.baseMapper.updateOrderUserCarByMap(map);
        if (count > 0) {
            return ResponseResult.success(BizCodeEnume.UPDATE_SUCCEEDED);
        }
        return ResponseResult.fail(BizCodeEnume.UPDATE_ERROR);
    }

    @Override
    public ResponseResult insertShoppingCartBatch(Map<String, Object> map) {
        String token = (String) map.get("token");
        boolean isExist = RedisUtil.exists(YFConfig.YF_USER_TOKEN_USER + token);
        if (isExist) {
            try {
                ObjectMapper mapper = new ObjectMapper();
                UserInfoVO ui = ParseTokenUtils.getUserInfoByToken(token);
                String userId = ui.getUserId();
                Integer commonId = Integer.parseInt(map.get("commonId").toString());
                Integer goodsNum = (Integer) map.get("goodsNum");
                // 加入购物车时间
                String insertCartTime = DateUtils.getNowDateToString();
                ResponseResult result = goodServiceClient.getGoodsCommonDetails(commonId);
                if (result.getCode() != CommonStatusEnum.SUCCESS.getCode()) {
                    return result;
                } else {
                    String goodsDetails = result.getData().toString();
                    // json转对象
                    List<ReceiveGoodsDetailsVO> receiveGoodsDetailList = JSON.parseArray(goodsDetails, ReceiveGoodsDetailsVO.class);
                    for (ReceiveGoodsDetailsVO receiveGoodsDetails : receiveGoodsDetailList) {
                        Integer shopId = receiveGoodsDetails.getShopId();
                        String shopName = receiveGoodsDetails.getShopName();
                        String goodsName = receiveGoodsDetails.getGoodsName();
                        String goodsImage = receiveGoodsDetails.getGoodsImage();
                        BigDecimal goodsPrice = receiveGoodsDetails.getGoodsPrice();
                        Integer goodsStock = receiveGoodsDetails.getGoodsStock();
                        String goodsSpecChineseValue = receiveGoodsDetails.getGoodsSpecChineseValue();
                        Integer cartStatus = receiveGoodsDetails.getCartStatus();
                        Integer goodsStatus = null;
                        if (cartStatus == 1) {
                            goodsStatus = 0;
                        } else if (cartStatus == 2) {
                            goodsStatus = 1;
                        } else if (cartStatus == 0) {
                            goodsStatus = 2;
                        }
                        // 判断购物车是否存在该商品(查询goodsId)
                        OrderUserCartEntity entity = this.baseMapper.selectOne(new LambdaQueryWrapper<OrderUserCartEntity>()
                                .eq(OrderUserCartEntity::getUserId, userId)
                                .eq(OrderUserCartEntity::getGoodsId, receiveGoodsDetails.getGoodsId())
                                .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode()));
                        Integer queryGoodsId = entity.getGoodsId();
                        Integer goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                        if (receiveGoodsDetails.getGoodsId().equals(queryGoodsId)) {
                            if (goodsNum > goodsMaxSale || goodsNum > goodsStock) {
                                this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                        .eq(OrderUserCartEntity::getUserId, userId)
                                        .eq(OrderUserCartEntity::getGoodsId, receiveGoodsDetails.getGoodsId())
                                        .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode())
                                        .set(OrderUserCartEntity::getGoodsNum, goodsMaxSale)
                                        .set(OrderUserCartEntity::getInsertCartTime, insertCartTime));
                                return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                            } else {
                                Integer cartGoodsNum = entity.getGoodsNum();
                                if (cartGoodsNum > goodsMaxSale) {
                                    this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                            .eq(OrderUserCartEntity::getUserId, userId)
                                            .eq(OrderUserCartEntity::getGoodsId, receiveGoodsDetails.getGoodsId())
                                            .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode())
                                            .set(OrderUserCartEntity::getGoodsNum, goodsMaxSale)
                                            .set(OrderUserCartEntity::getInsertCartTime, insertCartTime));
                                    return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                                } else {
                                    // 增加商品数量
                                    Boolean IsSuccess = this.baseMapper.updateGoodsNum(userId, receiveGoodsDetails.getGoodsId(), goodsNum, insertCartTime);// 增加商品数量
                                    if (IsSuccess) {
                                        return ResponseResult.fail(BizCodeEnume.OPERATION_SUCCESSFUL);
                                    } else {
                                        return ResponseResult.fail(BizCodeEnume.OPERATION_FAILED);
                                    }
                                }
                            }
                        } else {
                            OrderUserCartEntity data = new OrderUserCartEntity();
                            data.setUserId(userId);
                            data.setShopId(shopId);
                            data.setShopName(shopName);
                            data.setCommonId(commonId);
                            data.setGoodsId(receiveGoodsDetails.getGoodsId());
                            data.setGoodsName(goodsName);
                            data.setGoodsImage(goodsImage);
                            data.setGoodsNum(goodsNum);
                            data.setGoodsPrice(goodsPrice.doubleValue());
                            data.setGoodsStock(goodsStock);
                            data.setGoodsSpecChineseValue(goodsSpecChineseValue);
                            data.setInsertCartTime(DateUtils.getNowDate());
                            data.setCartStatus(goodsStatus);
                            data.setGoodsType(receiveGoodsDetails.getGoodsType());
                            // 插入购物车
                            boolean IsSuccess = this.baseMapper.insert(data) > 0;
                            if (IsSuccess) {
                                return ResponseResult.fail(BizCodeEnume.OPERATION_SUCCESSFUL);
                            } else {
                                return ResponseResult.fail(BizCodeEnume.OPERATION_FAILED);
                            }
                        }
                    }
                }
                return ResponseResult.fail(BizCodeEnume.OPERATION_SUCCESSFUL);
            } catch (Exception e) {
                log.info("insertShoppingCartErrorResults:" + e.getMessage());
                return ResponseResult.fail(e.getMessage());
            }
        } else {
            return ResponseResult.fail(BizCodeEnume.TOKEN_IS_INVALID);
        }
    }

    @Override
    public ResponseResult reduceGoodsNum(Map<String, Object> map) {

        String token = (String) map.get("token");
        try {
            UserInfoVO ui = ParseTokenUtils.getUserInfoByToken(token);
            if (ui == null) {
                return ResponseResult.fail(BizCodeEnume.USER_DOES_NOT_EXIST);
            }
            //获取用户权限
            UserTokenBeanDTO userTokenBean = new UserTokenBeanDTO();
            userTokenBean.setToken(token);
            String userId = ui.getUserId();
            Integer goodsId = (Integer) map.get("goodsId");
            ResponseResult goodResult = goodServiceClient.getGoodsDetails(goodsId);
            if (goodResult.getCode() != 1) {
                return ResponseResult.fail(BizCodeEnume.NO_INFORMATION_OBTAINED);
            }
            String goodsDetails = goodResult.getData().toString();
            // json转对象
            ReceiveGoodsDetailsDTO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                    ReceiveGoodsDetailsDTO.class);
            Integer goodsMinSale = receiveGoodsDetails.getGoodsMinSale();
            // 判断购物车是否存在该商品(查询goodsId)
            OrderUserCartEntity entity = this.baseMapper.selectOne(new LambdaQueryWrapper<OrderUserCartEntity>()
                    .eq(OrderUserCartEntity::getUserId, userId)
                    .eq(OrderUserCartEntity::getGoodsId, receiveGoodsDetails.getGoodsId())
                    .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode()));
            Integer goodsNum = map.get("goodsNum") == null ? entity.getGoodsNum() - 1 : (Integer) map.get("goodsNum");
            if (goodsMinSale != null && goodsMinSale != 0 && entity.getGoodsNum() < goodsMinSale) {
                //宝贝数量小于范围
                return ResponseResult.fail(BizCodeEnume.TREASURES_IS_LESS_THAN_THE_RANGE);
            }
            Boolean isSuccess = this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                    .eq(OrderUserCartEntity::getUserId, userId)
                    .eq(OrderUserCartEntity::getGoodsId, goodsId)
                    .eq(OrderUserCartEntity::getCartStatus, 0)
                    .set(OrderUserCartEntity::getGoodsNum, goodsNum)) > 0;
            if (isSuccess) {
                return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL.getMsg());
            } else {
                return ResponseResult.fail(BizCodeEnume.OPERATION_FAILED);
            }

        } catch (Exception e) {
            e.printStackTrace();
            return ResponseResult.fail(e.getMessage());

        }
    }

    @Override
    public ResponseResult addGoodsNum(Map<String, Object> map) {
        String token = (String) map.get("token");
        boolean isExist = RedisUtil.exists(YFConfig.YF_USER_TOKEN_USER + token);
        if (isExist) {
            try {

                UserInfoVO ui = ParseTokenUtils.getUserInfoByToken(token);
                String userId = ui.getUserId();
                Integer goodsId = (Integer) map.get("goodsId");
                ResponseResult goodResult = goodServiceClient.getGoodsDetails(goodsId);
                if (goodResult.getCode() != 1) {
                    return ResponseResult.fail(BizCodeEnume.NO_INFORMATION_OBTAINED);
                } else {
                    String goodsDetails = goodResult.getData().toString();
                    // json转对象
                    ReceiveGoodsDetailsDTO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                            ReceiveGoodsDetailsDTO.class);
                    // 最大限购数
                    Integer goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
                    // 库存
                    Integer goodsStock = receiveGoodsDetails.getGoodsStock();
                    //当前购物车数量
                    Integer goodsNum = this.baseMapper.selectOne(new LambdaQueryWrapper<OrderUserCartEntity>()
                            .eq(OrderUserCartEntity::getUserId, userId).eq(OrderUserCartEntity::getGoodsId, goodsId)
                            .eq(OrderUserCartEntity::getCartStatus, 0)).getGoodsNum();
                    if(Objects.equals(receiveGoodsDetails.getCommonIsXian(), CommonType.promotionStatus.SECKILL.getCode())){
                        AppSeckillGoodsQueryResultVO seckillGoodsVO = receiveGoodsDetails.getActivityGoodsDetail().getSeckillGoods();
                        Integer seckillNum = seckillGoodsVO.getSeckillNum();
                        Integer commonNum = this.baseMapper.selectCommonNumByUserId(userId,receiveGoodsDetails.getCommonId());
                        if(commonNum + 1 > seckillNum){
                            return ResponseResult.fail(BizCodeEnume.ACTIVITY_LIMIT_PURCHASE_LIMIT);
                        }
                    }

                    if (goodsMaxSale == 0) {
                        if ((1 + goodsNum) > goodsStock || goodsNum >= goodsStock) {
                            return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                        } else {
                            Boolean IsSuccess = this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                    .eq(OrderUserCartEntity::getUserId, userId)
                                    .eq(OrderUserCartEntity::getGoodsId, goodsId)
                                    .eq(OrderUserCartEntity::getCartStatus, 0)
                                    .set(OrderUserCartEntity::getGoodsNum, goodsNum + 1)) > 0;
                            if (IsSuccess) {
                                return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL);
                            } else {
                                return ResponseResult.fail(BizCodeEnume.OPERATION_SUCCESSFUL);
                            }
                        }
                    } else {
                        if ((1 + goodsNum) > goodsStock || goodsNum >= goodsMaxSale || goodsNum >= goodsStock || ((1 + goodsNum) > goodsMaxSale)) {
                            return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);

                        } else {
                            Boolean IsSuccess = this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                    .eq(OrderUserCartEntity::getUserId, userId)
                                    .eq(OrderUserCartEntity::getGoodsId, goodsId)
                                    .eq(OrderUserCartEntity::getCartStatus, 0)
                                    .set(OrderUserCartEntity::getGoodsNum, goodsNum)) > 0;
                            if (IsSuccess) {
                                return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL);
                            } else {
                                return ResponseResult.fail(BizCodeEnume.OPERATION_SUCCESSFUL);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                log.info("addGoodsNumErrorResults:" + e.getMessage());
                return ResponseResult.fail(e.getMessage());
            }
        } else {
            return ResponseResult.fail(BizCodeEnume.TOKEN_IS_INVALID);

        }

    }

    /**
     * 添加商品进入购物车
     *
     * @param userId
     * @param goodsId
     * @param goodsNum
     * @param sellerShopId
     * @return
     * @throws JsonProcessingException
     */
    private ResponseResult addShoppingCart(String userId, Integer goodsId, Integer goodsNum, String sellerShopId) throws JsonProcessingException {
        // 加入购物车时间
        Date insertCartTime = DateUtils.getNowDate();
        //查询商品详情
        ResponseResult goodsDetailsResult = goodServiceClient.getGoodsDetails(goodsId);

        if (goodsDetailsResult.getCode() != CommonStatusEnum.SUCCESS.getCode()) {
            return goodsDetailsResult;
        } else {
            String goodsDetails = goodsDetailsResult.getData().toString();
            // json转对象
            ReceiveGoodsDetailsDTO receiveGoodsDetails = JsonUtils.string2Obj(goodsDetails,
                    ReceiveGoodsDetailsDTO.class);
            Integer virtualGoods = receiveGoodsDetails.getVirtualGoods();
            if (null != virtualGoods && 0 == virtualGoods) {
                return ResponseResult.fail(BizCodeEnume.VIRTUAL_PRODUCT_CANNOT_BE_ADDED_TO_SHOPPING_CART);

            }
            Integer shopId = receiveGoodsDetails.getShopId();
            String shopName = receiveGoodsDetails.getShopName();
            Integer commonId = receiveGoodsDetails.getCommonId();
            String goodsName = receiveGoodsDetails.getGoodsName();
            String goodsImage = receiveGoodsDetails.getGoodsImage();
            BigDecimal goodsPrice = receiveGoodsDetails.getGoodsPrice();
            Integer goodsStock = receiveGoodsDetails.getGoodsStock();
            String goodsSpecChineseValue = receiveGoodsDetails.getGoodsSpec();
            Integer cartStatus = receiveGoodsDetails.getCartStatus();
            Integer goodsStatus = null;
            if (cartStatus != null && cartStatus == 1) {
                goodsStatus = 0;
            } else if (cartStatus != null && cartStatus == 2) {
                goodsStatus = 1;
            } else if (cartStatus != null && cartStatus == 0) {
                goodsStatus = 2;
            }
            if (sellerShopId != null && sellerShopId.toString().equals(shopId.toString())) {
                return ResponseResult.fail(BizCodeEnume.DO_NOT_PURCHASE_YOUR_OWN_PRODUCTS);
            }

            // 判断购物车是否存在该商品(查询goodsId)
            OrderUserCartEntity userCartEntity = this.baseMapper.selectOne(new LambdaQueryWrapper<OrderUserCartEntity>()
                    .eq(OrderUserCartEntity::getUserId, userId)
                    .eq(OrderUserCartEntity::getGoodsId, goodsId)
                    .eq(OrderUserCartEntity::getCartStatus, CommonType.shoppingCartStatus.NORMAL.getCode()));
            Integer goodsMaxSale = receiveGoodsDetails.getGoodsMaxSale();
            //购物车现有数量
            Integer cartGoodsNum = 0;
            if (userCartEntity != null && goodsId.equals(userCartEntity.getGoodsId())) {
                cartGoodsNum = userCartEntity.getGoodsNum();
                //goodsMaxSale为0是不限购商品
                if (goodsMaxSale == 0) {
                    if (goodsNum > goodsStock || (goodsNum + cartGoodsNum) > goodsStock) {
                        return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                    } else {
                        // 增加商品数量
                        int flag = this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                .eq(OrderUserCartEntity::getUserId, userId)
                                .eq(OrderUserCartEntity::getGoodsId, goodsId)
                                .set(OrderUserCartEntity::getGoodsNum, userCartEntity.getGoodsNum() + goodsNum)
                                .set(OrderUserCartEntity::getInsertCartTime, insertCartTime));
                        Boolean isSuccess = flag > 0;
                        goodsNum = goodsNum + userCartEntity.getGoodsNum();
                        return cartChangNumRedis(userId, goodsNum, goodsId, isSuccess);
                    }
                } else {
                    if (goodsNum > goodsMaxSale || goodsNum > goodsStock || (cartGoodsNum + goodsNum) > goodsMaxSale || (cartGoodsNum + goodsNum) > goodsStock) {
                        return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                    } else {
                        // 增加商品数量
                        int flag = this.baseMapper.update(null, new LambdaUpdateWrapper<OrderUserCartEntity>()
                                .eq(OrderUserCartEntity::getUserId, userId)
                                .eq(OrderUserCartEntity::getGoodsId, goodsId)
                                .set(OrderUserCartEntity::getGoodsNum, userCartEntity.getGoodsNum() + goodsNum)
                                .set(OrderUserCartEntity::getInsertCartTime, insertCartTime));
                        Boolean isSuccess = flag > 0;
                        goodsNum = goodsNum + userCartEntity.getGoodsNum();
                        return cartChangNumRedis(userId, goodsNum, goodsId, isSuccess);
                    }
                }
            } else {
                //不限购
                if (goodsMaxSale == 0) {
                    if (goodsNum > goodsStock) {
                        return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                    } else {
                        String s = String.valueOf(receiveGoodsDetails.getMoq());
                        Integer goodsType = receiveGoodsDetails.getGoodsType();
                        // 插入购物车
                        boolean isSuccess = insertUserCart(userId, shopId, shopName, commonId, goodsId, goodsName,
                                goodsImage, goodsNum, goodsPrice, goodsStock, goodsSpecChineseValue, insertCartTime,
                                goodsStatus, receiveGoodsDetails.getGoodsType());
                        return insertCartIsSuccess(userId, isSuccess);
                    }
                } else {
                    //限购
                    if (goodsNum > goodsMaxSale || goodsNum > goodsStock) {
                        return ResponseResult.fail(BizCodeEnume.TREASURES_IS_OUT_OF_RANGE);
                    } else {
                        // 插入购物车
                        boolean isSuccess = insertUserCart(userId, shopId, shopName, commonId, goodsId, goodsName, goodsImage, goodsNum, goodsPrice, goodsStock, goodsSpecChineseValue, insertCartTime, goodsStatus, receiveGoodsDetails.getGoodsType());
                        return insertCartIsSuccess(userId, isSuccess);
                    }
                }
            }
        }
    }

    /**
     * 改变购物车商品数量并更新缓存
     *
     * @param userId
     * @param goodsNum
     * @param queryGoodsId
     * @param isSuccess
     * @throws JsonProcessingException
     */
    private ResponseResult cartChangNumRedis(String userId, Integer goodsNum, Integer queryGoodsId, Boolean isSuccess) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        if (isSuccess) {
//            String jsonString = RedisUtil.get("yuanfeng_cart_userId_" + userId);
//            if (jsonString != null) {
//                Integer length = 0;
//                Integer index = 0;
//                JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, EntityObjectsDTO.class);
//                List<EntityObjectsDTO> cartListByShopNameList = mapper.readValue(jsonString, javaType);
//                for (EntityObjectsDTO entityObjects : cartListByShopNameList) {
//                    List<UserShoppingCartDTO> goodsList = (List<UserShoppingCartDTO>) entityObjects.getGoodsDetailsList();
//                    //直接用上面的强制数据会报错，因为强制的时候转坏的
//                    //可以把list转成json
//                    String str = JSON.toJSONString(goodsList);
//                    //再把json转成list
//                    goodsList = JSONObject.parseArray(str, UserShoppingCartDTO.class);
//                    if (length == 1) {
//                        cartListByShopNameList.get(index).setGoodsDetailsList(goodsList);
//                        index++;
//                        continue;
//                    }
//                    for (UserShoppingCartDTO userShoppingCart : goodsList) {
//                        if (userShoppingCart.getGoodsId() != null && queryGoodsId.equals(userShoppingCart.getGoodsId())) {
//                            userShoppingCart.setGoodsNum(goodsNum);
//                        }
//                    }
//                    cartListByShopNameList.get(index).setGoodsDetailsList(goodsList);
//                    index++;
//                }
//                RedisUtil.set("yuanfeng_cart_userId_" + userId, JsonUtils.toString(cartListByShopNameList), 60 * 60 * 24);
//            }
            return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL.getMsg());
        } else {
            return ResponseResult.fail(BizCodeEnume.OPERATION_FAILED);
        }
    }

    private ResponseResult insertCartIsSuccess(String userId, boolean isSuccess) {
        if (isSuccess) {
            RedisUtil.remove("yuanfeng_cart_userId_" + userId);
            return ResponseResult.success(CommonStatusEnum.SUCCESS.getValue());

        } else {
            return ResponseResult.fail(CommonStatusEnum.FAIL.getValue());
        }
    }

    /**
     * 插入购物车
     *
     * @param userId
     * @param shopId
     * @param shopName
     * @param commonId
     * @param goodsId
     * @param goodsName
     * @param goodsImage
     * @param goodsNum
     * @param goodsPrice
     * @param goodsStock
     * @param goodsSpecChineseValue
     * @param insertCartTime
     * @param goodsStatus
     * @param goodsType
     * @return
     */
    private Boolean insertUserCart(String userId, Integer shopId, String shopName, Integer commonId,
                                   Integer goodsId, String goodsName, String goodsImage, Integer goodsNum, BigDecimal goodsPrice,
                                   Integer goodsStock, String goodsSpecChineseValue, Date insertCartTime, Integer goodsStatus, Integer goodsType) {

        OrderUserCartEntity insertUserCartEntity = new OrderUserCartEntity();
        insertUserCartEntity.setUserId(userId);
        insertUserCartEntity.setShopId(shopId);
        insertUserCartEntity.setShopName(shopName);
        insertUserCartEntity.setCommonId(commonId);
        insertUserCartEntity.setGoodsId(goodsId);
        insertUserCartEntity.setGoodsName(goodsName);
        insertUserCartEntity.setGoodsImage(goodsImage);
        insertUserCartEntity.setGoodsNum(goodsNum);
        insertUserCartEntity.setGoodsPrice(Double.parseDouble(goodsPrice.toString()));
        insertUserCartEntity.setGoodsStock(goodsStock);
        insertUserCartEntity.setGoodsSpecChineseValue(goodsSpecChineseValue);
        insertUserCartEntity.setInsertCartTime(insertCartTime);
        insertUserCartEntity.setCartStatus(CommonType.shoppingCartStatus.NORMAL.getCode());
        insertUserCartEntity.setGoodsType(goodsType);

        int flag = this.baseMapper.insert(insertUserCartEntity);
        return flag == CommonStatusEnum.SUCCESS.getCode();

    }

    private Integer dealActivityInfo(String token, Integer goodsId, Integer activityStatus, Integer goodsMaxSale, Integer goodsStock) {
        Integer toBuyMaxNum = 0;
        Map<String, Object> param = new HashMap<>();

        if (2 == activityStatus) {//秒杀
            param.put("token", token);
            param.put("goodsId", goodsId);
            ResponseResult resp = activityServiceClient.seckillCheckLimit(param);
            Integer code = resp.getCode();
            Object data = resp.getData();
            //code 1 data null 不限购
            if (1 == code && data == null) {
                toBuyMaxNum = goodsStock;
                //code 2 data count 已达购买上限 data null 活动结束
            } else if (2 == code) {
                toBuyMaxNum = 0;
                //code 1 data count 未达上限，可购买
            } else if (1 == code && null != data) {
                toBuyMaxNum = goodsMaxSale - (Integer) data;

            }

        } else if (3 == activityStatus) {//限时折扣
            param.put("token", token);
            param.put("goodsId", goodsId);
            ResponseResult resp = activityServiceClient.discountCheckLimit(param);
            Integer code = resp.getCode();
            Object data = resp.getData();
            //code 1 data null 不限购
            if (1 == code && data == null) {
                toBuyMaxNum = goodsStock;
                //code 2 data count 已达购买上限 data null 活动结束
            } else if (2 == code) {
                toBuyMaxNum = 0;
                //code 1 data count 未达上限，可购买
            } else if (1 == code && null != data) {
                toBuyMaxNum = goodsMaxSale - (Integer) data;

            }


        }
        return toBuyMaxNum;


    }
}

